package com.xauto.pioneer.appuser.activity.user_aptitude;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.activity.BaseActivity;
import com.xauto.pioneer.appuser.activity.mine.balance.DepositTopUpActivity;
import com.xauto.pioneer.appuser.interfaces.MemberCallBack;
import com.xauto.pioneer.appuser.model.Member;
import com.xauto.pioneer.appuser.util.DataLoadUtil;
import com.xauto.pioneer.appuser.view.TopBar;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by lsx on 2018-03-01.
 */

public class UsreAptitudeActivity extends BaseActivity {

    @Bind(R.id.user_topBar)
    TopBar user_topBar;
    /*@Bind(R.id.user_idcard_layout)
    Layout user_idcard_layout;*/
    @Bind(R.id.user_idcard_text)
    TextView user_idcard_text;
    /*@Bind(R.id.user_mony_layout)
    Layout user_mony_layout;*/
    @Bind(R.id.user_mony_text)
    TextView user_mony_text;
    private Member member;

    @Override
    protected int getContentView() {
        return R.layout.layout_use_aptitude_info;
    }

    @Override
    protected void initView() {
        user_topBar.showView(TopBar.LEFT_IMAGE_BTN, TopBar.TITLE);
        user_topBar.setImage(TopBar.LEFT_IMAGE_BTN, R.mipmap.ic_common_left);
        user_topBar.setText(TopBar.TITLE, R.string.use_main_aptitude);
        user_topBar.setLeftOnClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
    @Override
    protected void onResume() {
        super.onResume();
        //刷新页面
        DataLoadUtil.refreshMemberData(mContext, new MemberCallBack() {
            @Override
            public void getMember(Member m) {
                member = m;
                setData(member);
            }
        });
    }
    @Override
    protected void onStart() {
        super.onStart();
        //刷新页面
        DataLoadUtil.refreshMemberData(mContext, new MemberCallBack() {
            @Override
            public void getMember(Member m) {
                member = m;
                setData(member);
            }
        });
    }
    private void setData(Member meb) {
        member = meb;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                //资质认证
                if(member.member_auth_info.member_auth_status.equals("1")) {
                    user_idcard_text.setText(getString(R.string.user_set_card_verified));
                }
                if(member.member_auth_info.member_auth_status.equals("0")) {
                    user_idcard_text.setText(getString(R.string.user_set_card_ver));
                }
                if(member.member_auth_info.member_auth_status.equals("2")) {
                    user_idcard_text.setText(getString(R.string.user_set_ing));
                }
                //保证金
                if(member.member_deposit_info.is_deposit.equals("1")) {
                    user_mony_text.setText(getString(R.string.user_set_card_verified));
                }
                if(member.member_deposit_info.is_deposit.equals("0")) {
                    user_mony_text.setText(getString(R.string.user_set_card_ver));
                }
                if(member.member_deposit_info.is_deposit.equals("2")) {
                    user_mony_text.setText(getString(R.string.user_set_deposit));
                }
            }
        });
    }
    @OnClick({R.id.user_idcard_layout, R.id.user_mony_layout})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.user_idcard_layout:
                //资质认证
                startActivity(new Intent(mContext, UserAptitudeFlowActivity.class));
                break;
            case R.id.user_mony_layout:
                //保证金认证
                startActivity(new Intent(mContext, DepositTopUpActivity.class));
                break;
        }
    }

    @Override
    protected void initData() {

    }
}